package com.zhaoxi.project.wms.controller;

import java.util.List;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.zhaoxi.framework.aspectj.lang.annotation.Log;
import com.zhaoxi.framework.aspectj.lang.enums.BusinessType;
import com.zhaoxi.project.wms.domain.MesTask;
import com.zhaoxi.project.wms.service.impl.MesTaskServiceImpl;
import com.zhaoxi.framework.web.BaseService;
import com.zhaoxi.framework.web.PageData;
import com.zhaoxi.common.utils.poi.ExcelUtil;
import com.zhaoxi.framework.web.page.TableDataInfo;

/**
 * 生产任务工单Controller
 *
 * @author zhaoxi
 * @date 2023-08-28
 */
@RestController
@RequestMapping("/mes/task")
public class MesTaskController extends BaseService
{
    @Autowired
    private MesTaskServiceImpl mesTaskService;

    /**
     * 查询生产任务工单列表
     */
    @PreAuthorize("@ss.hasPermi('wms:task:list')")
    @GetMapping("/list")
    public TableDataInfo list(MesTask mesTask)
    {
        startPage();
        List<MesTask> list = mesTaskService.selectMesTaskList(mesTask);
        return getDataTable(list);
    }

    /**
     * 导出生产任务工单列表
     */
    @PreAuthorize("@ss.hasPermi('wms:task:export')")
    @Log(title = "生产任务工单", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, MesTask mesTask)
    {
        List<MesTask> list = mesTaskService.selectMesTaskList(mesTask);
        ExcelUtil<MesTask> util = new ExcelUtil<MesTask>(MesTask.class);
        util.exportExcel(response, list, "生产任务工单数据");
    }

    /**
     * 获取生产任务工单详细信息
     */
    @PreAuthorize("@ss.hasPermi('wms:task:query')")
    @GetMapping(value = "/{id}")
    public PageData getInfo(@PathVariable("id") Long id)
    {
        return success(mesTaskService.selectMesTaskById(id));
    }

    /**
     * 新增生产任务工单
     */
    @PreAuthorize("@ss.hasPermi('wms:task:add')")
    @Log(title = "生产任务工单", businessType = BusinessType.INSERT)
    @PostMapping
    public PageData add(@RequestBody MesTask mesTask)
    {
        return toAjax(mesTaskService.insertMesTask(mesTask));
    }

    /**
     * 修改生产任务工单
     */
    @PreAuthorize("@ss.hasPermi('wms:task:edit')")
    @Log(title = "生产任务工单", businessType = BusinessType.UPDATE)
    @PutMapping
    public PageData edit(@RequestBody MesTask mesTask)
    {
        return toAjax(mesTaskService.updateMesTask(mesTask));
    }

    /**
     * 删除生产任务工单
     */
    @PreAuthorize("@ss.hasPermi('wms:task:remove')")
    @Log(title = "生产任务工单", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public PageData remove(@PathVariable Long[] ids)
    {
        return toAjax(mesTaskService.deleteMesTaskByIds(ids));
    }
}
